<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    
// 筛选   map 是北方的  并且  score 大于 6  并且  price 大于 5 并且  tag 是在 500 至 1100 之间的
let arrList = [ 
    {
        mentor_id: '1',
        price: '3',
        fruits: '香蕉',
        map: '南方',
        tag: '1001',
        score: 6
    },
    {
        mentor_id: '2',
        price: '6',
        fruits: '苹果',
        map: '北方',
        tag: '901',
        score: 10
    },
    {
        mentor_id: '2',
        price: '6',
        fruits: '苹果',
        map: '北方',
        tag: '901',
        score: 10
    },
    {
        mentor_id: '2',
        price: '6',
        fruits: '苹果',
        map: '北方',
        tag: '901',
        score: 10
    },
    {
        mentor_id: '2',
        price: '6',
        fruits: '苹果',
        map: '北方',
        tag: '901',
        score: 10
    },
    {
        mentor_id: '2',
        price: '6',
        fruits: '苹果',
        map: '北方',
        tag: '901',
        score: 10
    },
    {
        mentor_id: '2',
        price: '6',
        fruits: '苹果',
        map: '北方',
        tag: '901',
        score: 10
    },
    {
        mentor_id: '3',
        price: '2',
        fruits: '菠萝',
        map: '南方',
        tag: '105',
        score: 7
    },
    {
        mentor_id: '4',
        price: '6',
        fruits: '梨',
        map: '北方',
        tag: '107',
        score: 2
    },
    {
        mentor_id: '5',
        price: '10',
        fruits: '西瓜',
        map: '北方',
        tag: '335',
        score: 5
    },
    {
        mentor_id: '6',
        price: '20',
        fruits: '草莓',
        map: '北方',
        tag: '865',
        score: 6
    },
    {
        mentor_id: '7',
        price: '16',
        fruits: '荔枝',
        map: '南方',
        tag: '455',
        score: 6
    },
    {
        mentor_id: '8',
        price: '6',
        fruits: '杨梅',
        map: '南方',
        tag: '108',
        score: 7
    },
    {
        mentor_id: '9',
        price: '6',
        fruits: '香瓜',
        map: '南方',
        tag: '1005',
        score: 8
    },
    {
        mentor_id: '10',
        price: '23',
        fruits: '甜瓜',
        map: '北方',
        tag: '1008',
        score: 9
    },
    {
        mentor_id: '11',
        price: '7',
        fruits: '哈密瓜',
        map: '南方',
        tag: '1006',
        score: 5
    },
    {
        mentor_id: '12',
        price: '5',
        fruits: '火龙果',
        map: '南方',
        tag: '1055',
        score: 4
    },
    {
        mentor_id: '13',
        price: '6',
        fruits: '百香果',
        map: '南方',
        tag: '1047',
        score: 3
    },
    {
        mentor_id: '14',
        price: '4',
        fruits: '榴莲',
        map: '北方',
        tag: '844',
        score: 4
    },
    {
        mentor_id: '15',
        price: '5',
        fruits: '芒果',
        map: '南方',
        tag: '845',
        score: 5
    },
    {
        mentor_id: '16',
        price: '4',
        fruits: '西红柿',
        map: '北方',
        tag: '846',
        score: 6
    },
    {
        mentor_id: '17',
        price: '1',
        fruits: '苦瓜',
        map: '北方',
        tag: '847',
        score: 7
    },
    {
        mentor_id: '18',
        price: '5',
        fruits: '石榴',
        map: '北方',
        tag: '701',
        score: 9
    }
]
// 筛选   map是北方的  并且score 大于6  并且price 大于5并且  tag 是在500至1100之间的

/* 方法1 
    //筛选
    var a = arrList.filter((val,i)=>{
        return  val.map == "北方" && (val.score>6) && (val.price > 5) && (val.tag >=500 && val.tag <1100)
    })
    //数组对象去重 
    var hash = {};  
    a = a.reduce(function(item, next) {
        hash[next] ? '' : hash[next] = true && item.push(next);
        return item
    }, [])
    console.log(a);
*/


//筛选
let handleArr = [];
for (let i = 0; i < arrList.length; i++) {
    let it = arrList[i];
    if(it.map === "北方" && it.score>6 && it.price>5 &&(it.tag >=500 && it.tag <1100)){
        handleArr.push(arrList[i])
    }
}
console.log(handleArr)
//去重
 var result = [];           //利用对象访问属性的方法，判断对象中是否存在key
    var obj = {};
    for(var i =0; i<handleArr.length; i++){     
      if(!obj[handleArr[i].key]){   
         result.push(handleArr[i]);
          obj[handleArr[i].key] = true;
      }
    }
console.log(result)






</script>